# -*- coding: utf-8 -*-
import urllib2
import urllib
import json

WEIXIN_APP_ID = 'wx51fbc35ef855f874'
WEIXIN_APP_SECRET = '67816460b2dd0f8751e9fa6469433bbc'
DOUBAN_API_KEY = '0dd85940c5670b0b29890bc250352121'


def weixin_get_access_token(appid, appsecret):
    ACCESS_TOKEN_URL = 'https://api.weixin.qq.com/cgi-bin/token'
    params = {
        'grant_type': 'client_credential',
        'appid': appid.encode('utf-8'),
        'secret': appsecret.encode('utf-8'),
    }
    url = ACCESS_TOKEN_URL + '?' + urllib.urlencode(params)
    resp = urllib2.urlopen(url)
    r = json.loads(resp.read())
    return r
